package com.suoluo.zenadmin.service.crawler.resolver;

import java.io.IOException;
import java.util.Iterator;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

//import com.suoluo.cubetravel.admin.crawler.resolver.impl.hotels.HotelReviewStatImpl;

public class Connect {

	/**
	 * <div class="searchresult_info_name searchresult_info_name2"> <h2 class="searchresult_name">
	 * <a target="_blank"
	 * data-ctm="#ctm_ref=hi_0_0_0_0_lst_sr_1_df_ls_1_n_hi_0_0_0"
	 * href="/international/89086.html">Diamond Cliff Resort and Spa
	 * Phuket(普吉岛钻石崖度假村)</a> <span class="hotel_diamond05"
	 * title="普吉岛豪华酒店（携程用户评定为5钻）"></span></h2>
	 * <p class="searchresult_htladdress">
	 * <span> 普吉岛，284 Prabaramee Road, Patong, Phuket, Thailand( <a
	 * rel="nofollow" href="javascript:;" onclick="window.AMap.click(825)"
	 * title="芭东海滩酒店预订">芭东海滩地区</a> ) </span> <a class="link_map" href=
	 * "javascript:EMap.showPop('7.909127|98.297279', 'Diamond Cliff Resort and Spa Phuket(普吉岛钻石崖度假村)','89086', this);"
	 * rel="nofollow">地图/交通</a>
	 * </p>
	 * <p class="range">
	 * </p>
	 * <p class="info">
	 * 普吉岛钻石崖度假村位于芭东海滩，傍山而建，度假村内环境宜人宛如一座城市花园一般。度假村客房设计别致温馨，以暖色调为主，装饰时尚、精致,
	 * 是一个情侣度蜜月的理想选择。
	 * </p>
	 * <div class="icon_list"> <span class="ico_wifi" title="公共区域WIFI"></span>
	 * <span class="ico_restaurant" title="餐厅"></span> <span class="ico_swim"
	 * title="游泳池"></span> <span class="ico_gym" title="健身房"></span> <span
	 * class="ico_spa" title="SPA"></span> </div> </div>
	 */
	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// HotelReviewStatImpl hotelReviewStatImpl = new HotelReviewStatImpl();
		Document doc = Jsoup
				.connect(
						"http://www.agoda.com.cn/europe/france/paris/princesse_caroline.html?asq=bs17wTmKLORqTfZUfjFABgXi3BORRY%2fwV6i%2fSo3sNAKowNEBkNeMfLN0rvfGTiV6%2fK7Pj%2fc9%2bnTtTSygE0GSFBWz2f%2bY%2bbArzxYHmQcRXLP4ev4EHncCPF8Loq2qYCC8wxYwP%2b7jlkPdpyKZgzX9CsEO0AHkfVLvGy%2flka2XcY0C7kxfzQIo%2bYb4BEHge914JnwolIyyiO9g1%2btxvA6MyS316uFFvx882WJUz%2bc0uzwcPYmpzluBm9Rhd8900SgfQD1m8qpi4gffzZnlfPiVVg%3d%3d&tyra=1|1")
				.get();
		
		String reviewCount = doc.select("div#ctl00_ctl00_MainContent_ContentMain_ThumbPhotos_divReviewScore").select("strong").text();
		System.out.println("总评论数：" + reviewCount);
		String reviewScore = doc.select("span#ctl00_ctl00_MainContent_ContentMain_ThumbPhotos_lblTotalScore").text();
		System.out.println("酒店评分：" + reviewScore);
		String reviewLevel =doc.select("span#ctl00_ctl00_MainContent_ContentMain_ThumbPhotos_llblScoreText").text();
		System.out.println("酒店级别:" + reviewLevel);
		
		
		Elements eles = doc.select("table.hotelreviewlist").select("tr");
		Iterator<Element> iter = eles.iterator();
		int temp = 0;
		while (iter.hasNext()) {
			if (temp == 5) {
				return;
			}
			Element ele = iter.next();
			// Elements hotelNameEle = ele.select("span.fn");
			//
			// Elements hotelDescEle = ele.select("blockquote.description");
			// Elements hotelValue = ele.getElementsByClass("span.rating");

			System.out
					.println("---------------------------------------------------");
			System.out.println("评论标题:" + ele.select("div.blue").text());
//			String ming = doc.select("b.rank_text").first().text();
//			ming = ming.substring(ming.indexOf('#') + 1);
			System.out.println("评论描述:"
					+ ele.select("span#ctl00_ctl00_MainContent_ContentMain_HotelReview1_rptHotelReviews_ctl01_lblCommentText").text());
			System.out.println("评论作者:" + ele.select("span#ctl00_ctl00_MainContent_ContentMain_HotelReview1_rptHotelReviews_ctl01_lblMemberName").text());
			System.out.println("评论时间:"
					+ ele.select("span#ctl00_ctl00_MainContent_ContentMain_HotelReview1_rptHotelReviews_ctl02_lblReviewDate").text());
			System.out.println("评论分数:"
					+ ele.select("span#ctl00_ctl00_MainContent_ContentMain_HotelReview1_rptHotelReviews_ctl01_lblGuestRating").text());
//			System.out.println("评论总分数:" + 5);
			temp++;
		}

	}

}
